﻿// <copyright file="InformationEntry.cs" company="SharpSTS">
// Copyright (c) 2007, 2008 All Right Reserved, http://sharpsts.com/
//
// This source is subject to the Microsoft Permissive License.
// Please see the License.txt file for more information.
// All other rights reserved.
//
// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 
// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// </copyright>
// <author>Barry Dorrans</author>
// <email>barryd@idunno.org</email>
// <date>2008-06-14</date>
// <summary>Represents the an information entry configuration element.</summary>

namespace SharpSTS.Configuration
{
    using System.Configuration;

    /// <summary>
    /// Represents an Information Entry that may be embedded inside an Information Card.
    /// </summary>
    /// <remarks>
    /// For more details see http://blogs.msdn.com/card/archive/2007/10/24/providing-custom-data-in-an-information-card.aspx
    /// </remarks>
    /// <example>
    /// &lt;add name="Customer Support" value="support@sharpsts.example" /&gt;
    /// </example>
    public sealed class InformationEntry : ConfigurationElement
    {
        /// <summary>
        /// The name configuration element attribute name.
        /// </summary>
        private const string NameAttribute = @"name";

        /// <summary>
        /// The value configuration element attribute name.
        /// </summary>
        private const string ValueAttribute = @"value";

        /// <summary>
        /// Gets or sets the name of the information entry.
        /// </summary>
        /// <value>The name of the information entry.</value>
        [ConfigurationProperty(NameAttribute, IsKey = true, IsRequired = true)]
        [StringValidator(MaxLength = 255, MinLength = 0)]
        public string Name
        {
            get
            {
                return ((string)(base[NameAttribute]));
            }

            set
            {
                base[NameAttribute] = value;
            }
        }

        /// <summary>
        /// Gets or sets the value of the information entry.
        /// </summary>
        /// <value>The value of the information entry.</value>
        [ConfigurationProperty(ValueAttribute, IsKey = false, IsRequired = true)]
        [StringValidator(MaxLength = 255, MinLength = 0)]
        public string Value
        {
            get
            {
                return ((string)(base[ValueAttribute]));
            }

            set
            {
                base[ValueAttribute] = value;
            }
        }
    }
}
